home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / TOOLPAS2 / HELPME.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-28  |  4KB  |  169 lines

  1.  
  2. unit Helpme;
  3.  
  4. interface
  5.    uses Crt, DispEdit, DosMem;
  6.  
  7. const
  8.    maxsub = 7;
  9.    maxkey = 200;
  10.    keylen = 30;
  11.  
  12. type
  13.    keyword_rec = record
  14.       loc:           word;
  15.       width,lines:   byte;
  16.       id:            string[keylen];
  17.    end;
  18.  
  19.    sublist_rec = array[1..maxsub] of byte;
  20.  
  21.    procedure help_on_tap(level:  integer;
  22.                          x,y:    integer;
  23.                          keyno:  byte;
  24.                          var     keytab;
  25.                          var     htext);
  26.  
  27.  
  28. implementation
  29.  
  30.    procedure help_on_tap(level:  integer;
  31.                          x,y:    integer;
  32.                          keyno:  byte;
  33.                          var     keytab;
  34.                          var     htext);
  35.    var
  36.       keywords:   array[1..maxkey] of keyword_rec absolute keytab;
  37.       help_text:  array[1..maxint] of byte absolute htext;
  38.       disp:       ^display_image_rec;
  39.       p:          integer;
  40.       str:        ^string;
  41.    const
  42.       ex:         char = '?';
  43.  
  44.  
  45.       procedure display_help;
  46.       begin
  47.          with keywords[keyno] do
  48.          begin
  49.             window(1,1,80,25);
  50.             textBackground(Black);
  51.             textColor(LightRed);
  52.  
  53.             while x+width+4 > 79 do
  54.                dec(x);
  55.             while y+lines+2 > 25 do
  56.                dec(y);
  57.             display_border(x,y,x+width+5,y+lines+2,single_border);
  58.  
  59.             textBackground(Blue);
  60.             textColor(White);
  61.             gotoxy(x+2,y);
  62.             write(id);
  63.  
  64.             window(x+1,y+1,x+width+3,y+lines+1);
  65.             textColor(Yellow);
  66.             clrscr;
  67.  
  68.             p := loc;
  69.             inc(p,maxsub);
  70.  
  71.             repeat
  72.                str := @help_text[p];
  73.                inc(p,length(str^)+1);
  74.  
  75.                if str^ <> #0 then
  76.                   displn(' '+str^);
  77.             until str^ = #0;
  78.          end;
  79.       end;
  80.  
  81.  
  82.       procedure process_subtopics;
  83.       var
  84.          subs: ^sublist_rec;
  85.          fld:  integer;
  86.          xx:   sublist_rec;
  87.          escx: integer;
  88.  
  89.       begin
  90.          with keywords[keyno] do
  91.          begin
  92.             textbackground(Black);
  93.             textcolor(white);
  94.  
  95.             subs := @help_text[loc];
  96.             for fld := 1 to maxsub do
  97.             begin
  98.                xx[fld] := wherex+1;
  99.                if subs^[fld] > 0 then
  100.                with keywords[subs^[fld]] do
  101.                begin
  102.                   gotoxy(wherex+1,wherey);
  103.                   write(' '+id+' ');
  104.                end;
  105.             end;
  106.  
  107.             escx := wherex+1;
  108.             fld := maxsub+2;
  109.             ex := DOWN;
  110.             if keyno <> 1 then
  111.                edit_funkey(display,escx,wherey,' Index ',F1,ex);
  112.  
  113.             repeat
  114.                if (fld = maxsub+1) and (keyno <> 1) then
  115.                   edit_funkey(edit,escx,wherey,' Index ',F1,ex)
  116.                else
  117.  
  118.                if fld = maxsub+2 then
  119.                   edit_funkey(edit,escx+8,wherey,' ESC ',ESC,ex)
  120.                else
  121.  
  122.                if subs^[fld] > 0 then
  123.                with keywords[subs^[fld]] do
  124.                   edit_funkey(edit,xx[fld],wherey,' '+id+' ',chr(fld+ord('@')),ex);
  125.  
  126.                ex := upcase(ex);
  127.                if ex = ' ' then ex := DOWN;
  128.                if (ex = ^H) or (ex = DEL) then ex := UP;
  129.                if ex = LEFT then ex := UP;
  130.                if ex = RIGHT then ex := DOWN;
  131.                select_next_entry(edit,fld,maxsub+2,ex);
  132.  
  133.                if (ex >= 'A') and (ex <= chr(maxsub+ord('@'))) then
  134.                   if (subs^[fld] > 0) then
  135.                   begin
  136.                      help_on_tap(level+1,x+2,y+1,subs^[fld],keytab,htext);
  137.                      if ex = ESC then
  138.                         ex := '?';
  139.                   end;
  140.  
  141.             until (ex = ESC) or (ex = F1);
  142.          end;
  143.       end;
  144.  
  145.  
  146.    begin
  147.       dos_getmem(disp,sizeof(disp^));
  148.       save_display(disp^);
  149.  
  150.       repeat
  151.          shadow_display;
  152.          display_help;
  153.          process_subtopics;
  154.  
  155.          if (ex = F1) and (level = 1) then
  156.          begin
  157.             keyno := 1;
  158.             ex := '?';
  159.          end;
  160.  
  161.          restore_display(disp^);
  162.       until (ex = ESC) or (ex = F1);
  163.  
  164.       dos_freemem(disp);
  165.    end;
  166.  
  167. end.
  168.  
  169.